import xlsxwriter
wb=xlsxwriter.Workbook('data.xlsx')
cell_format1=wb.add_format()
cell_format1.set_bold()
cell_format1.set_font_color('red')
cell_format1.set_font_size(14)
cell_format1.set_align('center')
cell_format2=wb.add_format({'bold':True})
cell_format2.set_bg_color('#808080')
sheet=wb.add_worksheet('rank')
sheet.merge_range(0,0,1,5,'EWTTA',cell_format1)
data=(
    (1,'王哲齐','男','右手横板两面反胶',1757,'第一次周赛甲组冠军'),
    (2,'刘奕辰','男','右手横板两面反胶',1710,'第二次周赛冠军'),
    (3,'张征','男','右手直板两面反胶',1650,'第三次周赛冠军，东体杯冠军')
    )
sheet.write_row(2,0,['排名','姓名','性别','打法','积分','备注'],cell_format2)
for index,item in enumerate(data):
    sheet.write_row(index+3,0,item)
sheet.write(6,4,"=sum(E4:E6)")
sheet.write_url(7,0,'http://www.baidu.com',string='百度一下，你就知道')
sheet.insert_image(8,0,'table.bmp')
chart=wb.add_chart({'type':'column'})
chart.set_title({'name':'选手信息统计'})
chart.set_x_axis({'name':'姓名'})
chart.set_y_axis({'name':'积分'})
chart.add_series({'name':'男',
                  'categories':'=rank!$B$4:$B$6',
                  'values':['rank',3,4,5,4],
                  'data_labels':{'value':True}
})
sheet.insert_chart('A26',chart)
wb.close()
